fix: refresh the clicked slot without the reopened view - #32
Conversation
The click refresh ran a tick later and read the raw slot from whatever view was open then. When a menu closed in between, the index could pass the countSlots check yet be past the player's 46-slot menu, throwing IndexOutOfBoundsException. Keep the clicked inventory and its own slot index from the event instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe click handler now captures the clicked inventory and its local slot before scheduling a refresh. On the next tick, it validates and refreshes that slot in the captured inventory. The online-player check and cursor refresh remain. ChangesGear refresh handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change addresses the stale-view slot lookup, and no actionable new risk was established for this PR. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change fixes the reported slot mismatch, but a deferred refresh can still modify the previously clicked inventory after the player leaves it. The effect is limited to a clicked slot, and no privilege escalation has been demonstrated; whether that write remains appropriate after a view change is unresolved. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
A rabbit watched the gear slots gleam Comment |
Live console on 0.4.2 was logging
IndexOutOfBoundsException: Index 46 out of bounds for length 46fromGearRefreshListenerline 49.The click refresh runs one tick after the click and read the raw slot from
player.getOpenInventory()at that point. If a chest or menu closed during that tick, the player was back in their own crafting view.countSlots()is top size + bottom size, which is larger than that menu's 46 real slots, so the bounds check passed andgetItemthrew.The listener now keeps
event.getClickedInventory()andevent.getSlot()from the click and refreshes that inventory directly, checking the slot against its size. The cursor refresh is unchanged.🤖 Generated with Claude Code
Summary by CodeRabbit